package com.pan.admin.generator.constant;

import com.gitee.apanlh.util.base.Eq;

/**
 *  生成字段枚举
 *
 *  @author Pan
 */
public enum ApiGenFieldEnum {

    PHONE_MD5(               "phoneMd5",               "手机号MD5"),
    PHONE_MASK(              "phoneMask",              "手机号掩码"),
    PHONE(                   "phone",                  "手机号"),
    CITY(                    "city",                   "城市"),
    AREA_CODE(               "areaCode",               "城市code"),
    BANK_CARD(               "bankCard",               "银行卡"),
    IDCARD(                  "idcard",                 "身份证"),
    USER_NAME(               "userName",               "姓名"),
    IP(                      "ip",                     "额外属性IP"),
    SEX(                     "sex",                    "性别"),
    PROVINCE_CODE(           "provinceCode",           "归属省份code"),
    PROVINCE_NAME(           "provinceName",           "归属省份名称"),

    /** ------------表单字段------------ */
    AGE(                     "age",                    "年龄"),
    SESAME_CREDIT(           "sesameCredit",           "芝麻分"),
    REAL_ESTATE_INFO(        "realEstateInfo",         "房产情况"),
    CAR_INFO(                "carInfo",                "车辆情况"),
    SOCIAL_SECURITY(         "socialSecurity",         "社保缴纳"),
    INSURANCE_POLICY(        "insurancePolicy",        "保险保单"),
    CAREER(                  "career",                 "职业"),
    MONTHLY_SALARY(          "monthlySalary",          "月收入"),
    SALARY_PAY_METHOD(       "salaryPayMethod",        "收入形式/工资发放形式"),
    BIZ_PUB_ACC_BANK_DETAILS("bizPubAccBankDetails",   "对公账户经营收入"),
    BIZ_BANK_DETAILS(        "bizBankDetails",         "总经营流水"),
    BIZ_LICENSE_YEAR(        "bizLicenseYear",         "营业执照注册年限"),
    LOAN_AMOUNT(             "loanAmount",             "贷款金额"),
    PROVIDENT_FUND(          "providentFund",          "公积金"),
    CREDIT_LIMIT(            "creditLimit",            "信用卡额度"),
    HB_LIMIT(                "hbLimit",                "蚂蚁花呗可用额度"),
    BT_LIMIT(                "btLimit",                "京东白条可用额度"),
    OVERDUE(                 "overdue",                "信用情况(逾期)"),
    EDUCATION_ATTAINMENT(    "educationAttainment",    "学历"),
    YEARS_SERVICE(           "yearsService",           "单位工龄"),
    LOAN_PURPOSE(            "loanPurpose",            "借款用途"),
    ;

    /** 字段名称 */
    private String fieldName;
    /** 字段名称中文名 */
    private String fieldChineseName;

    ApiGenFieldEnum(String fieldName, String fieldChineseName) {
        this.fieldName = fieldName;
        this.fieldChineseName = fieldChineseName;
    }

    public String getFieldName() {
        return fieldName;
    }

    public String getFieldChineseName() {
        return fieldChineseName;
    }

    public String getGenDoc() {
        return ApiGenFieldDocConstant.getDoc(this);
    }

    public static ApiGenFieldEnum getByFieldName(String fieldName) {
        ApiGenFieldEnum[] values = ApiGenFieldEnum.values();
        for (ApiGenFieldEnum value : values) {
            if (Eq.str(value.getFieldName(), fieldName)) {
                return value;
            }
        }
        return null;
    }

    public static ApiGenFieldEnum getByName(String enumName) {
        ApiGenFieldEnum[] values = ApiGenFieldEnum.values();
        for (ApiGenFieldEnum value : values) {
            if (value.name().equals(enumName)) {
                return value;
            }
        }
        return null;
    }
}
